package com.lsege.controller.backstage;

import com.github.pagehelper.PageHelper;
import com.lsege.entity.JsonResult;
import com.lsege.entity.Page;
import com.lsege.entity.backstage.Customer;
import com.lsege.service.backstage.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by lsd on 2017-07-03.
 */
@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    CustomerService customerService;

    @GetMapping("selectCustomer")
    public JsonResult selectCustomer(Integer pageNum,Integer pageSize){
        JsonResult json = new JsonResult();
        PageHelper.startPage(pageNum,pageSize);
        List<Customer> list = customerService.selectCustomer();
        Long total = customerService.selectCustomerAll();
        json.setData(new Page(list,total,pageSize,pageNum));
        json.setSuccess(true);
        json.setMessage("获取成功");
        return json;
    }

}
